/******************************************************************************
  * @file    PT32X005_crc.h
  * @author  应用开发团队
  * @version V1.1.0
  * @date    2020/1/27
  * @brief    This file contains all the functions prototypes for the CRC firmware library.
  *
  ******************************************************************************
  * @attention
  *
  *
  *****************************************************************************/


/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef PT32X005_CRC_H
#define PT32X005_CRC_H

#ifdef __cplusplus
extern "C" {
#endif

/*!< Includes ------------------------------------------------------------*/
#include "PT32X005.h"


/** @addtogroup CRC
  * @{
  */

/* Exported types ---------------------------------------------------------*/

/** @brief  LED Init structure definition **/
typedef struct
{
	u32 CRC_DIN_Width;	/*!< Defines the source of Comparator positive input. This parametercan be a value of @ref  */
	FunctionalState Bit_Input_Reverse;
	FunctionalState Byte_Input_Reverse;	/*!< Specifies whether the ADC data alignment is left or right.This parameter can be a value of @ref ADC_data_align */
	FunctionalState Bit_Output_Reverse;	/*!< Specifies whether the ADC data alignment is left or right.This parameter can be a value of @ref ADC_data_align */
	u32 CRC_Seed;	/*!< Defines the source of Comparator positive input. This parameter can be a value of @ref  */
	u32 CRC_Poly;	/*!< Defines the source of Comparator positive input. This parameter can be a value of @ref  */
} CRC_InitTypeDef;

/* Exported constants --------------------------------------------------------*/
#define CRC_CR_MASK		0xFFFFFFFC
#define CRC_CCITT_POLY	0x00001021           // 0x1021
#define CRC_16_POLY		0x00008005           // 0x8005

#define IS_CRC_SEED_VAL(Value)	((Value) <= 0xFFFF)
#define IS_CRC_POLY_VAL(Value)	((Value) <= 0xFFFF)

#define IS_CRC_CIS_SEL(SEL)		((SEL == CRC_CIS_8b) || \
								(SEL == CRC_CIS_16b))

/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void CRC_Init(CRC_InitTypeDef* CRC_InitStruct);
void CRC_StructInit(CRC_InitTypeDef* CRC_InitStruct);
void CRC_Cmd(FunctionalState NewState);
void CRC_ResetDout(void);
u32 CRC_CalcCRC(u16 CRC_Data);
u32 CRC_CalcBlockCRC(u16 pBuffer[], u32 BufferLength);
u32 CRC_GetCRC(void);

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif


